package day12_coll.demo06_comparable;
////年龄相同时，按照姓名比较 就是倒序（从大到小）
public class Student implements Comparable<Student>{
    @Override
    public int compareTo(Student o) {
        int sum=o.age-this.age;
        int i=(sum==0)?this.name.compareTo(o.name):sum;
        return i;
    }
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Student() {
    }


}
